//
//  TalkManage.h
//  QuanZiChat
//
//  Created by lanou3g on 15/11/25.
//  Copyright © 2015年 ZhongHongLin. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>

#define ManagerObjectModelFileName @"UserModel"

@interface TalkManage : NSObject
//管理对象上下文(用来操作数据库的管理者对象
@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
//持久化存储协调器(管理数据库的类型,链接管理和被管理对象)
@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
//管理对象模型(数据库中的表,被管理对象)
@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;

+(instancetype)defulManage;

//将聊天记录保存到本地
//-(void)addContentWithEntityForType:(NSNumber *)type Time:(NSString *)time Message:(NSString *)message UserID:(NSString *)userID Username:(NSString *)username;

//从本地获取存储的好友信息
-(NSArray *)getbackFriendMessageFromCocaDataWithUsername:(NSString *)username;


//从本地查询聊天记录
-(NSArray *)fetchWithUserID:(NSString *)userID EntityForName:(NSString *)entityname;

//从本地查询所有聊天的人
-(NSArray *)fetchTalkWithMyID:(NSString *)myID;

//输出路径
- (NSURL *)applicationDocumentsDirectory;

/**
 时间戳转换为正常的时间
 */
- (NSString *)getNowTime:(NSInteger )time;

//从本地数据库获取会话内容按时间排序
-(void)getMessageSortWithClick:(NSString *)click;


//保存上下文
- (void)saveContext;

@end
